import { defineConfig } from 'vite'
import Uni from '@dcloudio/vite-plugin-uni'
import UniHelperManifest from '@uni-helper/vite-plugin-uni-manifest'
import UniHelperPages from '@uni-helper/vite-plugin-uni-pages'
import UniHelperLayouts from '@uni-helper/vite-plugin-uni-layouts'
import UniHelperComponents from '@uni-helper/vite-plugin-uni-components'
import AutoImport from 'unplugin-auto-import/vite'
import UnoCSS from 'unocss/vite'
import shake from 'vue-event-shake'

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [
    // https://github.com/uni-helper/vite-plugin-uni-manifest
        UniHelperManifest(),
        // https://github.com/uni-helper/vite-plugin-uni-pages
        UniHelperPages({
            dts: 'src/uni-pages.d.ts',
            subPackages: ['src/package-mine', 'src/package-clock', 'src/package-advance'],
            homePage: 'pages/mine/mine',
        }),
        // https://github.com/uni-helper/vite-plugin-uni-layouts
        UniHelperLayouts(),
        // https://github.com/uni-helper/vite-plugin-uni-components
        UniHelperComponents({
            dts: 'src/components.d.ts',
            directoryAsNamespace: true,
        }),
        Uni(),
        // https://github.com/antfu/unplugin-auto-import
        AutoImport({
            imports: ['vue', '@vueuse/core', 'uni-app'],
            dts: 'src/auto-imports.d.ts',
            dirs: ['src/composables', 'src/stores', 'src/utils'],
            vueTemplate: true,
        }),
        // https://github.com/antfu/unocss
        // see unocss.config.ts for config
        UnoCSS(),
        shake(),
    ],
    build: {
        rollupOptions: {
            external: ['@dcloudio/uni-ui'],
        },
    },
    css: {
        preprocessorOptions: {
            scss: {
                silenceDeprecations: ['legacy-js-api'],
            },
        },
    },
})
